package com.iengine.services.api.command.music;

import com.iengine.services.api.utils.Constant;
import com.iengine.services.api.utils.OperationName;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings({"unchecked","rawtypes"})
public class CommandSystemVolume extends AbstractMusicPhoneApiCommand{
	/**
	 * ClassName[String]:CommandSystemVolume
	 *	arg-list:
	 *	VolumnLevel[String]:大点声/小点声
	 */
	public static final String FIELD_VOLUMN_LEVEL= "VolumnLevel";

	@Override
	protected Map formatArgs(Map map, Map nlpParams) {
		
		String volumnLevel = getValue(nlpParams.get(FIELD_VOLUMN_LEVEL),null);
		Map<String,Object> resultMap=new HashMap<String,Object>();
		if(StringUtils.isNoneBlank(volumnLevel)){
			Map<String,Object> levelParameter=new HashMap<String,Object>();
			if(StringUtils.equalsIgnoreCase(volumnLevel, OperationName.mediaVolumeMin.toString())){
				levelParameter.put(Constant.OPERATION_NAME, OperationName.mediaVolumeMin.name());
			}
			if(StringUtils.equalsIgnoreCase(volumnLevel, OperationName.mediaVolumeDecrease.toString())){
				levelParameter.put(Constant.OPERATION_NAME, OperationName.mediaVolumeDecrease.name());
			}
			if(StringUtils.equalsIgnoreCase(volumnLevel, OperationName.mediaVolumeComfortable.toString())){
				levelParameter.put(Constant.OPERATION_NAME, OperationName.mediaVolumeComfortable.name());
			}
			if(StringUtils.equalsIgnoreCase(volumnLevel, OperationName.mediaVolumeIncrease.toString())){
				levelParameter.put(Constant.OPERATION_NAME, OperationName.mediaVolumeIncrease.name());
			}
			if(StringUtils.equalsIgnoreCase(volumnLevel, OperationName.mediaVolumeMax.toString())){
				levelParameter.put(Constant.OPERATION_NAME, OperationName.mediaVolumeMax.name());
			}
			resultMap.put(Constant.COMMAND_NAME, Constant.COMMAND_SYSTEM_VOLUME);
			resultMap.put(Constant.DATA, levelParameter);
		}
//		map.put("cmdType", "mediaControl");
		map.put(Constant.COMMAND_DATA, resultMap);
		return map;
	}
}
